<?php
# !!!!!!!!!! DON'T MAKE ANY CHANGE IF YOU DON'T KNOW WHAT YOU'RE DOING !!!!!!!!!!
// --------------------------------------------------------------------------------------------------------------
// File Name              :	waiting_orders.php
// Last Modification Time	:	2008-02-01 24:00
// Last Modified by       :	turker (turker.biz@gmail.com)
// list of modifications  :
//
//	- 2008-02-01 turker
//		* 24:00 file created.
//
// --------------------------------------------------------------------------------------------------------------
if (eregi("waiting_orders.php",$_SERVER['PHP_SELF'])) {
	header ("Location:../index.php");
	exit;
}

if (!isLogged()||!isAdmin()) {
	header ("Location:$SITE_URL/");
	exit;
}

?>
<!--div:icerik -->
    <div id="icerik">
      <p>
      <h1>Bekleyen Siparişler</h1><br />
      <div id="ajax" style="display:none;"><img src="template/img/loading.gif" title="Yükleniyor..." /></div>
<?php
// id, basket_ids, buy, buy_date, send, send_date, address, order_note, admin_note, user_id, total
$q=$mysql->query("select * from $ORDERS_TABLE where buy='1' and send='0' order by buy_date asc");
if ($mysql->numRows($q)>0) {
  echo <<<html
  <link rel="stylesheet" href="template/tabber.css" type="text/css" media="screen" />
  <script type="text/javascript" src="template/tabber.js"></script>
  <link rel="stylesheet" href="template/src/css/shadowbox.css" type="text/css" media="screen" />
  <script type="text/javascript" src="template/src/js/adapter/shadowbox-jquery.js"></script>
  <script type="text/javascript" src="template/src/js/shadowbox.js"></script>
  <script type="text/javascript">
  $(document).ready(function(){
    var SHBoxOptions = {
      displayNav: false,
      handleUnsupported: 'remove',
      keysClose: ['c', 27] // c or esc
    };
    Shadowbox.init(SHBoxOptions);

    $("#delete").click(function(){
      var ids="";
      $("input[name='process']:checked").each(function(){
        ids=ids+"&del[]="+$(this).val();
      });
      if(ids!='') {
        if (confirm("Seçilen Siparişleri Silmek İstediğinze emin misiniz?")) {
          $("#ajax").slideDown();
          $.ajax({
            data: "do=order_del"+ids,
            success: function(msg){
              eval(msg);
            }
          });
          $("#ajax").slideUp();
        }
      }
      else alert("En az bir tane sipariş seçmelisiniz");
    });

    $("input[name='approve']").each(function(){
      $(this).click(function(){
        if(confirm("Siparişi onaylıyor musunuz?")) {
          var id=$(this).attr('id');
          var note=$("#admin_note_"+id).val();
          $("#ajax").slideDown();
          $.ajax({
            data: "do=order_ok&id="+id+"&note="+note,
            success: function(msg){
              eval(msg);
            }
          });
          $("#ajax").slideUp();
        }
      });
    });

  });</script>
html;
    echo '<table cellpadding="2" cellspacing="1" width="100%">';
    echo '<tr><th align="center">Sil</th><th align="center">Tarih</th><th align="center">Tutar</th>
    <th align="center">Onay</th><th>Sipariş Notu</th><th align="center">Yönetici Notu</th></tr>';
    while ($read=$mysql->fetch($q)) {
    	$id=$read['id'];
    	$buy_date=$read['buy_date'];
    	$total=$read['total'];
    	$order_note=$prep->html($read['order_note']);
    	$buy_date=strftime("%d&nbsp;%b&nbsp;%y&nbsp;%a&nbsp;%H:%M",$buy_date);
    	$buy_date=iconv("ISO-8859-9", "UTF-8",$buy_date);

    	$send_link="index.php?page=orders&id=$id";
    	echo '<tr id="order_'.$id.'"><td align="center"><input type="checkbox" name="process" value="'.$id.'" /></td>
    	      <td align="center"><a rel="shadowbox;width=760;height=555" title="Sipariş Detayı" href="'.$send_link.'">'.$buy_date.'</a></td>
    	      <td align="right">'.$total.'&nbsp;YTL</td>
    	      <td align="center"><input type="button" name="approve" id="'.$id.'" value=" Onayla " /></td>
    	      <td><div style="overflow:auto;width:20em;height:3em;white-space: nowrap;">'.$order_note.'</div></td>
    	      <td><input type="text" id="admin_note_'.$id.'" size="25" /></td>
    	      </tr>';
    }
    echo '<tr><td colspan="4"><input type="button" name="delete" id="delete" value=" Seçilen Siparişleri Sil " /></td>
    </tr>';
    echo '</table><br />';
}
else echo '<br />Bekleyen sipariş yok<br />';
?>
      </p>
    </div>
<!--//div:icerik -->